#include <stdio.h>
#include <stdlib.h>

int main()
{
    //定义一个文件指针
    FILE *in, *out;
    char ch, out_name[10], in_name[10];
    printf("请输入读入的文件名字:");
    scanf("%s", in_name);
    printf("请输入输出的文件名字:");
    scanf("%s", out_name);
    if ((in = fopen(in_name, "r")) == NULL)
    {
        printf("无法打开文件！");
        exit(0);
    }
    if ((out = fopen(out_name, "w")) == NULL)
    {
        printf("无法打开文件!");
        exit(0);
    }
    //从输入文件读取一个字符，并赋给变量ch
    ch = fgetc(in);
    while (!feof(in))
    {
        fputc(ch, out);
        putchar(ch);
        ch = fgetc(in);
    }
    fclose(in);
    fclose(out);
    system("pause");

    return 0;
}